package com.interview.item.javabase.session;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @Author:zxh
 * @Description:
 * @Date: 2020/4/1
 * @Modified By:
 */
@RestController
@RequestMapping("/one")
public class SessionController {
    private static Logger logger = LoggerFactory.getLogger(SessionController.class);



    @RequestMapping(value = "/two", method = RequestMethod.GET)
    public String test(HttpServletRequest request) {
        HttpSession session = request.getSession();
        String id = session.getId();
        session.setAttribute("sessionOne", "sessionOne");
        logger.info("two1-id输出：{}",id);
        logger.info("two12输出：{}",session.getAttribute("sessionOne"));
        logger.info("two2输出：{}",session.getAttribute("sessionTwo"));
        return session.getId();
    }

    @RequestMapping(value = "/three", method = RequestMethod.GET)
    public String test1(HttpServletRequest request) {
        HttpSession session = request.getSession();
        String id = session.getId();
        session.setAttribute("sessionTwo", "sessionTwo");
        logger.info("test1 id输出：{}",id);
        logger.info("test1输出：{}",session.getAttribute("sessionTwo"));
        logger.info("test2输出：{}",session.getAttribute("sessionOne"));
        return session.getId();
    }

    //1.session设置的过期时间  没有过期这一说
    //2.session更新  没有更新这一说
    //3.



}
